//package com.zeno.soil.codegeneration.application.service;
//
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import com.zeno.soil.codegeneration.application.entity.CodeGenerationSetting;
//import com.zeno.soil.codegeneration.application.entity.DatasourceSetting;
//import com.zeno.soil.codegeneration.application.entity.PersistenceTierCodeGeneration;
//import com.zeno.soil.codegeneration.application.entity.ThreeTierCodeGeneration;
//import com.zeno.soil.codegeneration.assembler.TableInfoForPersistenceObjectAssembler;
//import com.zeno.soil.codegeneration.domain.persistencetier.entity.PersistenceObject;
//import com.zeno.soil.codegeneration.domain.tableinfo.TableInfoService;
//import com.zeno.soil.codegeneration.domain.tableinfo.entity.DatabaseConnection;
//import com.zeno.soil.codegeneration.domain.tableinfo.entity.TableInfo;
//import com.zeno.soil.spring.boot.jdbc.constant.DatabaseTypeConstants;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//
//import java.util.Collection;
//import java.util.List;
//
///**
// * @author zeno
// * @date 2022/8/7 17:35
// */
//@Service
//public class CodeGenerationService {
//
//	private TableInfoService tableInfoService;
//
//	private ThreeTierArchitectureGenerator threeTierArchitectureGenerator;
//
//	public void generateSourceCodeFiles(String architectureType,
//	                                    DatasourceSetting datasourceSetting,
//										String databaseName,
//	                                    List<String> tableNames,
//	                                    CodeGenerationSetting codeGenerationSetting){
//
//
//		DatabaseConnection databaseConnection = createDatabaseConnection(datasourceSetting);
//		Collection<TableInfo> tableInfos = tableInfoService.getTableInfos(databaseConnection, databaseName, tableNames);
//		if (CollectionUtils.isEmpty(tableInfos)){
//			return;
//		}
//
//		switch (architectureType){
//			case DatabaseTypeConstants.MYSQL:
//				break;
//		}
//
//	}
//
//	private ThreeTierCodeGeneration createThreeTierCodeGenerationSetting(String databaseType,
//	                                                                     Collection<TableInfo> tableInfos,
//	                                                                     CodeGenerationSetting generationSetting) {
//
//		ThreeTierCodeGeneration threeTierCodeGeneration = new ThreeTierCodeGeneration();
//		PersistenceTierCodeGeneration persistenceTierCodeGeneration = createPersistenceTierCodeGeneration(databaseType, tableInfos, generationSetting);
//		threeTierCodeGeneration.setPersistenceTierCodeGeneration(persistenceTierCodeGeneration);
//
//		return threeTierCodeGeneration;
//	}
//
//	private PersistenceTierCodeGeneration createPersistenceTierCodeGeneration(String databaseType,
//	                                                                          Collection<TableInfo> tableInfos,
//	                                                                          CodeGenerationSetting generationSetting){
//
//		List<PersistenceObject> persistenceObjects = TableInfoForPersistenceObjectAssembler.createPersistenceObject(
//			databaseType, tableInfos, generationSetting.getPersistenceTierSetting());
//
//		PersistenceTierCodeGeneration codeGeneration = new PersistenceTierCodeGeneration();
//		codeGeneration.setBaseDir(generationSetting.getBaseDir());
//		codeGeneration.setBasePackage(generationSetting.getBasePackage());
//		codeGeneration.setPersistenceObjects(persistenceObjects);
//
//		return codeGeneration;
//	}
//
//
//
//	private DatabaseConnection createDatabaseConnection(DatasourceSetting datasourceSetting) {
//		if (datasourceSetting == null) {
//			return null;
//		}
//		DatabaseConnection databaseConnection = new DatabaseConnection();
//		databaseConnection.setUrl(datasourceSetting.getUrl());
//		databaseConnection.setUsername(datasourceSetting.getUsername());
//		databaseConnection.setPassword(datasourceSetting.getPassword());
//
//		switch (datasourceSetting.getDbType()){
//			case DatabaseTypeConstants.MYSQL:
//				databaseConnection.setDriverName(com.mysql.cj.jdbc.Driver.class.getName());
//				break;
//		}
//
//		return databaseConnection;
//	}
//
//	@Autowired
//	public void setTableInfoService(TableInfoService tableInfoService) {
//		this.tableInfoService = tableInfoService;
//	}
//
//	@Autowired
//	public void setThreeTierArchitectureGenerator(ThreeTierArchitectureGenerator threeTierArchitectureGenerator) {
//		this.threeTierArchitectureGenerator = threeTierArchitectureGenerator;
//	}
//}
